package com.bwie.shop.controller;

import com.bwie.common.domain.Contract;
import com.bwie.common.domain.request.ReviewRequest;
import com.bwie.common.domain.request.ShopContractAddRequest;
import com.bwie.common.domain.response.ShopContractListResponse;
import com.bwie.common.result.Result;
import com.bwie.shop.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺合同控制层
 *
 * @author <a href="mailto:3364114353@qq.com">liuwenliang</a>
 * @version 1.0
 * @description: 店铺合同控制层
 * @date 2025/9/9 14:54
 */
@RestController
@RequestMapping("/shopContract")
@CrossOrigin
public class ShopContractController {

    @Autowired
    private ContractService contractService;


    /**
     * 合同列表
     * @return 列表数据
     */
    @GetMapping("/getContractList")
    public Result<List<ShopContractListResponse>> getContractList () {
        List<ShopContractListResponse> contractList = contractService.getContractList();
        return Result.success(contractList);
    }


    /**
     * 审核通过
     * @param reviewRequest
     * @return
     */
    @PostMapping("/pass")
    public Result pass (@RequestBody ReviewRequest reviewRequest) {
        contractService.pass(reviewRequest);
        return Result.success();
    }

    /**
     * 审核不通过
     * @param reviewRequest
     * @return
     */
    @PostMapping("/notPassed")
    public Result notPassed (@RequestBody ReviewRequest reviewRequest) {
        contractService.notPassed(reviewRequest);
        return Result.success();
    }

    /**
     * 合同新增
     * @param shopContractAddRequest 合同信息
     * @return 是否新增成功
     */
    @PostMapping("/add")
    public Result add (@RequestBody ShopContractAddRequest shopContractAddRequest) {
        contractService.add(shopContractAddRequest);
        return Result.success();
    }
}
